Update to rust-2015-04-02
authorAlex Crichton <alex@alexcrichton.com>
Thu, 2 Apr 2015 18:12:21 +0000 (11:12 -0700)
committerAlex Crichton <alex@alexcrichton.com>
Thu, 2 Apr 2015 23:28:53 +0000 (16:28 -0700)
Along the way, this also removes the ability to specify `[[lib]]` targets while
getting warnings. While we're at it remove nearly all unstable features that
Cargo is depending on as well!

37 files changed:
Cargo.lock
Cargo.toml
src/bin/cargo.rs
src/bin/read_manifest.rs
src/bin/verify_project.rs
src/cargo/core/package_id.rs
src/cargo/core/package_id_spec.rs
src/cargo/core/resolver/mod.rs
src/cargo/core/source.rs
src/cargo/core/summary.rs
src/cargo/lib.rs
src/cargo/ops/cargo_clean.rs
src/cargo/ops/cargo_compile.rs
src/cargo/ops/cargo_package.rs
src/cargo/ops/cargo_read_manifest.rs
src/cargo/ops/cargo_run.rs
src/cargo/ops/cargo_rustc/compilation.rs
src/cargo/ops/cargo_rustc/custom_build.rs
src/cargo/ops/cargo_rustc/engine.rs
src/cargo/ops/cargo_rustc/mod.rs
src/cargo/ops/cargo_test.rs
src/cargo/sources/path.rs
src/cargo/util/errors.rs
src/cargo/util/mod.rs
src/cargo/util/paths.rs
src/cargo/util/process_builder.rs
src/cargo/util/toml.rs
src/rustversion.txt
tests/support/mod.rs
tests/test_cargo_bench.rs
tests/test_cargo_compile.rs
tests/test_cargo_compile_custom_build.rs
tests/test_cargo_compile_git_deps.rs
tests/test_cargo_compile_path_deps.rs
tests/test_cargo_publish.rs
tests/test_cargo_test.rs
tests/tests.rs

index 96f58ff9ed0e2a1759c629b0b4dc7463a09fea06..6bc9a63f136a4951d515876e9870d7f1f715fbed 100644 (file)
@@ -4,26 +4,27 @@ version = "0.1.0"
 dependencies = [
  "advapi32-sys 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "curl 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
- "docopt 0.6.56 (registry+https://github.com/rust-lang/crates.io-index)",
+ "docopt 0.6.57 (registry+https://github.com/rust-lang/crates.io-index)",
  "env_logger 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "flate2 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)",
- "git2 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
- "git2-curl 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
- "glob 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)",
+ "flate2 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
+ "git2 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)",
+ "git2-curl 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
+ "glob 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
  "hamcrest 0.1.0 (git+https://github.com/carllerche/hamcrest-rust.git)",
  "kernel32-sys 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "libc 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
  "log 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "num_cpus 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "regex 0.1.24 (registry+https://github.com/rust-lang/crates.io-index)",
  "registry 0.1.0",
- "rustc-serialize 0.3.10 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rustc-serialize 0.3.11 (registry+https://github.com/rust-lang/crates.io-index)",
  "semver 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)",
- "tar 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)",
- "tempdir 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
- "term 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)",
+ "tar 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)",
+ "tempdir 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
+ "term 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
  "threadpool 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
- "time 0.1.22 (registry+https://github.com/rust-lang/crates.io-index)",
- "toml 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)",
+ "time 0.1.23 (registry+https://github.com/rust-lang/crates.io-index)",
+ "toml 0.1.20 (registry+https://github.com/rust-lang/crates.io-index)",
  "url 0.2.28 (registry+https://github.com/rust-lang/crates.io-index)",
  "winapi 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
@@ -60,17 +61,17 @@ dependencies = [
  "libc 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
  "libz-sys 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
  "openssl-sys 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)",
- "pkg-config 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
+ "pkg-config 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
 [[package]]
 name = "docopt"
-version = "0.6.56"
+version = "0.6.57"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
  "libc 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
  "regex 0.1.24 (registry+https://github.com/rust-lang/crates.io-index)",
- "rustc-serialize 0.3.10 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rustc-serialize 0.3.11 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
 [[package]]
@@ -84,7 +85,7 @@ dependencies = [
 
 [[package]]
 name = "flate2"
-version = "0.2.4"
+version = "0.2.5"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
  "libc 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -93,40 +94,40 @@ dependencies = [
 
 [[package]]
 name = "gcc"
-version = "0.3.3"
+version = "0.3.4"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 
 [[package]]
 name = "git2"
-version = "0.2.6"
+version = "0.2.7"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
  "bitflags 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "libc 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
- "libgit2-sys 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libgit2-sys 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)",
  "url 0.2.28 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
 [[package]]
 name = "git2-curl"
-version = "0.2.2"
+version = "0.2.3"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
  "curl 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
- "git2 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
+ "git2 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)",
  "log 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "url 0.2.28 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
 [[package]]
 name = "glob"
-version = "0.2.7"
+version = "0.2.8"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 
 [[package]]
 name = "hamcrest"
 version = "0.1.0"
-source = "git+https://github.com/carllerche/hamcrest-rust.git#80e7a1cbd6db9ec20bb1d61920e55a1af91a9eb2"
+source = "git+https://github.com/carllerche/hamcrest-rust.git#0a87716b6fe9a3feb4afc829923e0121285b8c50"
 
 [[package]]
 name = "kernel32-sys"
@@ -143,14 +144,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
 
 [[package]]
 name = "libgit2-sys"
-version = "0.2.8"
+version = "0.2.9"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
  "libc 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
- "libssh2-sys 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libssh2-sys 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)",
  "libz-sys 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
  "openssl-sys 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)",
- "pkg-config 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
+ "pkg-config 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
 [[package]]
@@ -163,13 +164,13 @@ dependencies = [
 
 [[package]]
 name = "libssh2-sys"
-version = "0.1.15"
+version = "0.1.16"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
  "libc 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
  "libz-sys 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
  "openssl-sys 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)",
- "pkg-config 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
+ "pkg-config 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
 [[package]]
@@ -177,7 +178,7 @@ name = "libz-sys"
 version = "0.1.2"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
- "pkg-config 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
+ "pkg-config 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
 [[package]]
@@ -198,7 +199,16 @@ name = "miniz-sys"
 version = "0.1.4"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
- "gcc 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
+ "gcc 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libc 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
+name = "num_cpus"
+version = "0.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "gcc 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
  "libc 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
@@ -207,15 +217,15 @@ name = "openssl-sys"
 version = "0.5.3"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
- "gcc 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
+ "gcc 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
  "libc 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
  "libressl-pnacl-sys 2.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
- "pkg-config 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
+ "pkg-config 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
 [[package]]
 name = "pkg-config"
-version = "0.3.2"
+version = "0.3.3"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 
 [[package]]
@@ -225,7 +235,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
 
 [[package]]
 name = "rand"
-version = "0.3.3"
+version = "0.3.6"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
  "libc 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -242,12 +252,12 @@ name = "registry"
 version = "0.1.0"
 dependencies = [
  "curl 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
- "rustc-serialize 0.3.10 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rustc-serialize 0.3.11 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
 [[package]]
 name = "rustc-serialize"
-version = "0.3.10"
+version = "0.3.11"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 
 [[package]]
@@ -257,20 +267,20 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
 
 [[package]]
 name = "tar"
-version = "0.2.7"
+version = "0.2.9"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 
 [[package]]
 name = "tempdir"
-version = "0.3.3"
+version = "0.3.4"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
- "rand 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rand 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
 [[package]]
 name = "term"
-version = "0.2.4"
+version = "0.2.5"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
  "kernel32-sys 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -284,19 +294,19 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
 
 [[package]]
 name = "time"
-version = "0.1.22"
+version = "0.1.23"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
- "gcc 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
+ "gcc 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
  "libc 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
 [[package]]
 name = "toml"
-version = "0.1.19"
+version = "0.1.20"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
- "rustc-serialize 0.3.10 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rustc-serialize 0.3.11 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
 [[package]]
@@ -305,7 +315,7 @@ version = "0.2.28"
 source = "registry+https://github.com/rust-lang/crates.io-index"
 dependencies = [
  "matches 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
- "rustc-serialize 0.3.10 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rustc-serialize 0.3.11 (registry+https://github.com/rust-lang/crates.io-index)",
 ]
 
 [[package]]
index 6f8cac34256e637816124e00954c0423d47bc747..070a1623d84de29806b6546988954ed0728c9467 100644 (file)
@@ -29,6 +29,7 @@ regex = "0.1.18"
 threadpool = "0.1.1"
 libc = "0.1.2"
 registry = { path = "src/registry" }
+num_cpus = "0.1"
 
 [target.i686-pc-windows-gnu]
 dependencies = { winapi = "0.1", advapi32-sys = "0.1", kernel32-sys = "0.1" }
index 83ad3087f6f2a9165162165f2932af033b274ec3..a0490a96dcc538342a458327774e08ac1ac0dcec 100644 (file)
@@ -1,4 +1,4 @@
-#![feature(core, exit_status, fs_ext)]
+#![cfg_attr(unix, feature(fs_ext))]
 
 extern crate cargo;
 extern crate env_logger;
@@ -153,18 +153,18 @@ fn execute(flags: Flags, config: &Config) -> CliResult<Option<()>> {
 }
 
 fn find_closest(cmd: &str) -> Option<String> {
-    match list_commands().iter()
-                            // doing it this way (instead of just .min_by(|c|
-                            // c.lev_distance(cmd))) allows us to only make
-                            // suggestions that have an edit distance of
-                            // 3 or less
-                            .map(|c| (lev_distance(&c, cmd), c))
-                            .filter(|&(d, _): &(usize, &String)| d < 4)
-                            .min_by(|&(d, _)| d) {
-        Some((_, c)) => {
-            Some(c.to_string())
-        },
-        None => None
+    let cmds = list_commands();
+    // Only consider candidates with a lev_distance of 3 or less so we don't
+    // suggest out-of-the-blue options.
+    let mut filtered = cmds.iter().map(|c| (lev_distance(&c, cmd), c))
+                                  .filter(|&(d, _)| d < 4)
+                                  .collect::<Vec<_>>();
+    filtered.sort_by(|a, b| a.0.cmp(&b.0));
+
+    if filtered.len() == 0 {
+        None
+    } else {
+        Some(filtered[0].1.to_string())
     }
 }
 
@@ -245,7 +245,7 @@ fn is_executable(path: &Path) -> bool {
 }
 #[cfg(windows)]
 fn is_executable(path: &Path) -> bool {
-    fs::metadata(path).map(|m| m.is_file()) == Ok(true)
+    fs::metadata(path).map(|m| m.is_file()).unwrap_or(false)
 }
 
 /// Get `Command` to run given command.
index d72f2a8cba32ab4793430cfceead95da8efa9fd6..bd8f9e36658dd1906fa4d85e1187eae4c87de840 100644 (file)
@@ -1,4 +1,5 @@
 use std::path::Path;
+use std::error::Error;
 
 use cargo::core::{Package, Source};
 use cargo::util::{CliResult, CliError, Config};
index dcef2c4798ddef4615932ecfd60a3207c4908446..076cfc2db6a7c9506a842f517f4743e22fc9fd58 100644 (file)
@@ -1,10 +1,11 @@
 use std::collections::HashMap;
-use std::env;
 use std::fs::File;
 use std::io::prelude::*;
+use std::process;
 
-use toml;
 use cargo::util::{CliResult, Config};
+use rustc_serialize::json;
+use toml;
 
 pub type Error = HashMap<String, String>;
 
@@ -32,10 +33,10 @@ pub fn execute(args: Flags, config: &Config) -> CliResult<Option<Error>> {
     let file = File::open(&args.flag_manifest_path);
     match file.and_then(|mut f| f.read_to_string(&mut contents)) {
         Ok(_) => {},
-        Err(e) => return fail("invalid", &format!("error reading file: {}", e))
+        Err(e) => fail("invalid", &format!("error reading file: {}", e))
     };
     match toml::Parser::new(&contents).parse() {
-        None => return fail("invalid", "invalid-format"),
+        None => fail("invalid", "invalid-format"),
         Some(..) => {}
     };
 
@@ -44,9 +45,9 @@ pub fn execute(args: Flags, config: &Config) -> CliResult<Option<Error>> {
     Ok(Some(h))
 }
 
-fn fail(reason: &str, value: &str) -> CliResult<Option<Error>>{
+fn fail(reason: &str, value: &str) -> {
     let mut h = HashMap::new();
     h.insert(reason.to_string(), value.to_string());
-    env::set_exit_status(1);
-    Ok(Some(h))
+    println!("{}", json::encode(&h).unwrap());
+    process::exit(1)
 }
index 336ee96ecefc4858eb8f36ee7dc8599e93492b0d..992e06b9e4073dc2a9075f1afb6893fa92dbb49a 100644 (file)
@@ -1,5 +1,5 @@
 use std::cmp::Ordering;
-use std::error::{Error, FromError};
+use std::error::Error;
 use std::fmt::{self, Formatter};
 use std::hash::Hash;
 use std::hash;
@@ -108,8 +108,8 @@ impl CargoError for PackageIdError {
     fn is_human(&self) -> bool { true }
 }
 
-impl FromError<PackageIdError> for Box<CargoError> {
-    fn from_error(t: PackageIdError) -> Box<CargoError> { Box::new(t) }
+impl From<PackageIdError> for Box<CargoError> {
+    fn from(t: PackageIdError) -> Box<CargoError> { Box::new(t) }
 }
 
 #[derive(PartialEq, Eq, Hash, Clone, RustcEncodable, Debug)]
index e65c599805ebb40b841bb4fb5414e59e8ab287b6..d69a461bc7157df0fd6fb5fe4d91cb36770b9f0e 100644 (file)
@@ -26,7 +26,7 @@ impl PackageIdSpec {
                 }
             }
         }
-        let mut parts = spec.splitn(1, ':');
+        let mut parts = spec.splitn(2, ':');
         let name = parts.next().unwrap();
         let version = match parts.next() {
             Some(version) => Some(try!(Version::parse(version).map_err(human))),
@@ -69,7 +69,7 @@ impl PackageIdSpec {
             }));
             match frag {
                 Some(fragment) => {
-                    let mut parts = fragment.splitn(1, ':');
+                    let mut parts = fragment.splitn(2, ':');
                     let name_or_version = parts.next().unwrap();
                     match parts.next() {
                         Some(part) => {
index 8c2f7b8f6d431129a59aa0490c3e0108b4c461d9..a33614dc108492540fe8f86fa1a09482df2e9ad7 100644 (file)
@@ -541,7 +541,7 @@ fn build_features(s: &Summary, method: Method)
         // form `foo` and we need to recurse to enable the feature `foo` for our
         // own package, which may end up enabling more features or just enabling
         // a dependency.
-        let mut parts = feat.splitn(1, '/');
+        let mut parts = feat.splitn(2, '/');
         let feat_or_package = parts.next().unwrap();
         match parts.next() {
             Some(feat) => {
index f186e342e5d66b7b5908cdb4e890fdb21a5f522a..8a89c55466d3d5f74fcc3d4ff75924069596ec4a 100644 (file)
@@ -99,7 +99,7 @@ impl SourceId {
     ///                     656c58fb7c5ef5f12bc747f".to_string());
     /// ```
     pub fn from_url(string: String) -> SourceId {
-        let mut parts = string.splitn(1, '+');
+        let mut parts = string.splitn(2, '+');
         let kind = parts.next().unwrap();
         let url = parts.next().unwrap();
 
index 53513855270006adef788211fcaa90faef86a779..81445d2a3cbf54cb01815942b8a38db2519acbe2 100644 (file)
@@ -34,7 +34,7 @@ impl Summary {
         }
         for (feature, list) in features.iter() {
             for dep in list.iter() {
-                let mut parts = dep.splitn(1, '/');
+                let mut parts = dep.splitn(2, '/');
                 let dep = parts.next().unwrap();
                 let is_reexport = parts.next().is_some();
                 if !is_reexport && features.get(dep).is_some() { continue }
index 8cf9d8ab4702b46d79da21b75d40af5237c7e714..3738e97fe3c64a8f87825594f91f66bf61b72ac1 100644 (file)
@@ -1,18 +1,19 @@
 #![deny(unused)]
-#![feature(os, std_misc, core, path_relative_from, collections)]
-#![feature(io, str_words, exit_status, fs_time, convert)]
+#![feature(fs_time)]
 #![cfg_attr(test, deny(warnings))]
 
 #[cfg(test)] extern crate hamcrest;
 #[macro_use] extern crate log;
-extern crate rustc_serialize;
 extern crate curl;
 extern crate docopt;
 extern crate flate2;
 extern crate git2;
 extern crate glob;
 extern crate libc;
+extern crate num_cpus;
 extern crate regex;
+extern crate registry;
+extern crate rustc_serialize;
 extern crate semver;
 extern crate tar;
 extern crate term;
@@ -21,8 +22,6 @@ extern crate time;
 extern crate toml;
 extern crate url;
 
-extern crate registry;
-
 use std::env;
 use std::error::Error;
 use std::io::prelude::*;
@@ -180,7 +179,7 @@ pub fn handle_error(err: CliError, shell: &mut MultiShell) {
                                  with --verbose.".to_string(), BLACK);
     }
 
-    std::env::set_exit_status(exit_code);
+    std::process::exit(exit_code);
 }
 
 fn handle_cause(mut cargo_err: &CargoError, shell: &mut MultiShell) -> bool {
index 06fac5cc0b1ce3a2cb27d12964ec9f8b4f44f19c..ea25fc509d7a975cb00cdb3fb33117d84c85ec5a 100644 (file)
@@ -75,7 +75,7 @@ pub fn clean(manifest_path: &Path, opts: &CleanOptions) -> CargoResult<()> {
 
 fn rm_rf(path: &Path) -> CargoResult<()> {
     let m = fs::metadata(path);
-    if m.as_ref().map(|s| s.is_dir()) == Ok(true) {
+    if m.as_ref().map(|s| s.is_dir()).unwrap_or(false) {
         try!(fs::remove_dir_all(path).chain_error(|| {
             human("could not remove build directory")
         }));
index abe31a53a93e6049a93ede950d3cf8f390953f8e..12b1e0d8d3c7881f425be47e7fe82ab82c8dab9c 100644 (file)
@@ -24,7 +24,6 @@
 
 use std::collections::HashMap;
 use std::default::Default;
-use std::num::ToPrimitive;
 use std::path::{Path, PathBuf};
 use std::sync::Arc;
 
@@ -332,23 +331,19 @@ fn scrape_build_config(config: &Config,
                        -> CargoResult<ops::BuildConfig> {
     let cfg_jobs = match try!(config.get_i64("build.jobs")) {
         Some((n, p)) => {
-            match n.to_u32() {
-                Some(n) => Some(n),
-                None if n <= 0 => {
-                    return Err(human(format!("build.jobs must be positive, \
-                                              but found {} in {:?}", n, p)));
-                }
-                None => {
-                    return Err(human(format!("build.jobs is too large: \
-                                              found {} in {:?}", n, p)));
-                }
+            if n <= 0 {
+                return Err(human(format!("build.jobs must be positive, \
+                                          but found {} in {:?}", n, p)));
+            } else if n >= u32::max_value() as i64 {
+                return Err(human(format!("build.jobs is too large: \
+                                          found {} in {:?}", n, p)));
+            } else {
+                Some(n as u32)
             }
         }
         None => None,
     };
-    #[allow(deprecated)]
-    fn num_cpus() -> u32 { ::std::os::num_cpus() as u32 }
-    let jobs = jobs.or(cfg_jobs).unwrap_or(num_cpus());
+    let jobs = jobs.or(cfg_jobs).unwrap_or(::num_cpus::get() as u32);
     let mut base = ops::BuildConfig {
         jobs: jobs,
         requested_target: target.clone(),
index 6b7ef6132cbbc490233ae8924597d5a037ccf304..0392580a8ca82e94642a3c83323675ebe22fc036 100644 (file)
@@ -39,7 +39,7 @@ pub fn package(manifest_path: &Path,
     if list {
         let root = pkg.root();
         let mut list: Vec<_> = try!(src.list_files(&pkg)).iter().map(|file| {
-            file.relative_from(&root).unwrap().to_path_buf()
+            util::without_prefix(&file, &root).unwrap().to_path_buf()
         }).collect();
         list.sort();
         for file in list.iter() {
@@ -123,7 +123,7 @@ fn tar(pkg: &Package, src: &PathSource, config: &Config,
     let root = pkg.root();
     for file in try!(src.list_files(pkg)).iter() {
         if &**file == dst { continue }
-        let relative = file.relative_from(&root).unwrap();
+        let relative = util::without_prefix(&file, &root).unwrap();
         let relative = try!(relative.to_str().chain_error(|| {
             human(format!("non-utf8 path in source directory: {}",
                           relative.display()))
index 39c7f9edd4a3f5d22971ea10833e902ab1157d8a..2ac4e00211d00de510cbd5eed55286da77d9b107 100644 (file)
@@ -1,5 +1,4 @@
 use std::collections::HashSet;
-use std::error::FromError;
 use std::fs::{self, File};
 use std::io::prelude::*;
 use std::io;
@@ -77,7 +76,7 @@ pub fn read_packages(path: &Path, source_id: &SourceId, config: &Config)
 fn walk<F>(path: &Path, callback: &mut F) -> CargoResult<()>
     where F: FnMut(&Path) -> CargoResult<bool>
 {
-    if fs::metadata(&path).map(|m| m.is_dir()) != Ok(true) {
+    if !fs::metadata(&path).map(|m| m.is_dir()).unwrap_or(false) {
         return Ok(())
     }
 
@@ -93,7 +92,7 @@ fn walk<F>(path: &Path, callback: &mut F) -> CargoResult<()>
         Err(ref e) if e.kind() == io::ErrorKind::PermissionDenied => {
             return Ok(())
         }
-        Err(e) => return Err(FromError::from_error(e)),
+        Err(e) => return Err(From::from(e)),
     };
     for dir in dirs {
         let dir = try!(dir).path();
index 5f5a3611322750e3e2c9b5130a587fdd3515f076..79bd505c5a1add15d31782c08d1feed88c1cfea2 100644 (file)
@@ -1,7 +1,7 @@
 use std::path::Path;
 
 use ops::{self, ExecEngine, CompileFilter};
-use util::{CargoResult, human, process, ProcessError};
+use util::{self, CargoResult, human, process, ProcessError};
 use core::source::Source;
 use sources::PathSource;
 
@@ -47,7 +47,7 @@ pub fn run(manifest_path: &Path,
 
     let compile = try!(ops::compile(manifest_path, options));
     let exe = &compile.binaries[0];
-    let exe = match exe.relative_from(config.cwd()) {
+    let exe = match util::without_prefix(&exe, config.cwd()) {
         Some(path) => path,
         None => &**exe,
     };
index f5d384ebf07625bda9c9869586014b8c142f4b78..553fbd13db593beb31ffd58ad8169e2d1349871e 100644 (file)
@@ -1,5 +1,5 @@
 use std::collections::{HashMap, HashSet};
-use std::ffi::AsOsStr;
+use std::ffi::OsStr;
 use std::path::PathBuf;
 use semver::Version;
 
@@ -72,15 +72,15 @@ impl Compilation {
     }
 
     /// See `process`.
-    pub fn target_process<T: AsOsStr + ?Sized>(&self, cmd: &T, pkg: &Package)
+    pub fn target_process<T: AsRef<OsStr>>(&self, cmd: T, pkg: &Package)
                                                -> CargoResult<CommandPrototype> {
-        self.process(CommandType::Target(cmd.as_os_str().to_os_string()), pkg)
+        self.process(CommandType::Target(cmd.as_ref().to_os_string()), pkg)
     }
 
     /// See `process`.
-    pub fn host_process<T: AsOsStr + ?Sized>(&self, cmd: &T, pkg: &Package)
+    pub fn host_process<T: AsRef<OsStr>>(&self, cmd: T, pkg: &Package)
                                              -> CargoResult<CommandPrototype> {
-        self.process(CommandType::Host(cmd.as_os_str().to_os_string()), pkg)
+        self.process(CommandType::Host(cmd.as_ref().to_os_string()), pkg)
     }
 
     /// Prepares a new process with an appropriate environment to run against
index 73e042ba0fa42521037d30a4d9ceca65f1c4091f..c64d3e49ec2d47a458652221b77b2a98cefb935a 100644 (file)
@@ -155,7 +155,7 @@ pub fn prepare(pkg: &Package, target: &Target, req: Platform,
         // This is also the location where we provide feedback into the build
         // state informing what variables were discovered via our script as
         // well.
-        let output = try!(str::from_utf8(&output.stdout).chain_error(|| {
+        let output = try!(str::from_utf8(&output.stdout).map_err(|_| {
             human("build script output was not valid utf-8")
         }));
         let parsed_output = try!(BuildOutput::parse(output, &pkg_name));
@@ -256,7 +256,7 @@ impl BuildOutput {
         let whence = format!("build script of `{}`", pkg_name);
 
         for line in input.lines() {
-            let mut iter = line.splitn(1, |c| c == ':');
+            let mut iter = line.splitn(2, ':');
             if iter.next() != Some("cargo") {
                 // skip this line since it doesn't start with "cargo:"
                 continue;
@@ -267,7 +267,7 @@ impl BuildOutput {
             };
 
             // getting the `key=value` part of the line
-            let mut iter = data.splitn(1, |c| c == '=');
+            let mut iter = data.splitn(2, '=');
             let key = iter.next();
             let value = iter.next();
             let (key, value) = match (key, value) {
@@ -301,9 +301,9 @@ impl BuildOutput {
 
     pub fn parse_rustc_flags(value: &str, whence: &str)
                              -> CargoResult<(Vec<PathBuf>, Vec<String>)> {
-        // TODO: some arguments (like paths) may contain spaces
         let value = value.trim();
-        let mut flags_iter = value.words();
+        let mut flags_iter = value.split(|c: char| c.is_whitespace())
+                                  .filter(|w| w.chars().any(|c| !c.is_whitespace()));
         let (mut library_links, mut library_paths) = (Vec::new(), Vec::new());
         loop {
             let flag = match flags_iter.next() {
index 124a56dce36973bd51d98919446087586fa2d7c3..b9c1ca1f1e0ed5b30a0e6a1aeb35c5b333f35c4c 100644 (file)
@@ -1,5 +1,5 @@
 use std::collections::HashMap;
-use std::ffi::{AsOsStr, OsString};
+use std::ffi::{OsStr, OsString};
 use std::fmt;
 use std::path::Path;
 use std::process::Output;
@@ -49,23 +49,23 @@ impl CommandPrototype {
 
     pub fn get_type(&self) -> &CommandType { &self.ty }
 
-    pub fn arg<T: AsOsStr + ?Sized>(&mut self, arg: &T) -> &mut CommandPrototype {
+    pub fn arg<T: AsRef<OsStr>>(&mut self, arg: T) -> &mut CommandPrototype {
         self.builder.arg(arg);
         self
     }
 
-    pub fn args<T: AsOsStr>(&mut self, arguments: &[T]) -> &mut CommandPrototype {
+    pub fn args<T: AsRef<OsStr>>(&mut self, arguments: &[T]) -> &mut CommandPrototype {
         self.builder.args(arguments);
         self
     }
 
-    pub fn cwd<T: AsOsStr + ?Sized>(&mut self, path: &T) -> &mut CommandPrototype {
+    pub fn cwd<T: AsRef<OsStr>>(&mut self, path: T) -> &mut CommandPrototype {
         self.builder.cwd(path);
         self
     }
 
-    pub fn env<T: AsOsStr + ?Sized>(&mut self, key: &str, val: &T)
-                                    -> &mut CommandPrototype {
+    pub fn env<T: AsRef<OsStr>>(&mut self, key: &str, val: T)
+                                -> &mut CommandPrototype {
         self.builder.env(key, val);
         self
     }
index 0415a9c7c3e3984ad58d16e6a56108163df9fdca..46cef33b97a607a48b6032203880894b190cc5ca 100644 (file)
@@ -600,7 +600,9 @@ fn root_path(cx: &Context, pkg: &Package, target: &Target) -> PathBuf {
     let absolute = pkg.root().join(target.src_path());
     let cwd = cx.config.cwd();
     if absolute.starts_with(cwd) {
-        absolute.relative_from(cwd).map(|s| s.to_path_buf()).unwrap_or(absolute)
+        util::without_prefix(&absolute, cwd).map(|s| {
+            s.to_path_buf()
+        }).unwrap_or(absolute)
     } else {
         absolute
     }
index e32807e8d038993e43e2af958e378c9d2efd8ea5..a5993284e0d2d91da8d92678ff196b49f2a862a6 100644 (file)
@@ -4,7 +4,7 @@ use std::path::Path;
 use core::Source;
 use sources::PathSource;
 use ops::{self, ExecEngine, ProcessEngine, Compilation};
-use util::{CargoResult, ProcessError};
+use util::{self, CargoResult, ProcessError};
 
 pub struct TestOptions<'a, 'b: 'a> {
     pub compile_opts: ops::CompileOptions<'a, 'b>,
@@ -91,7 +91,7 @@ fn build_and_run(manifest_path: &Path,
 
     let cwd = config.cwd();
     for &(_, ref exe) in &compile.tests {
-        let to_display = match exe.relative_from(&cwd) {
+        let to_display = match util::without_prefix(exe, &cwd) {
             Some(path) => path,
             None => &**exe,
         };
index 49c7504162d99c8bd2159d3f38b18862038acc0c..3e2ea0f0892fbd56bad327a67bef7e7b0f63d1bf 100644 (file)
@@ -9,7 +9,7 @@ use git2;
 
 use core::{Package, PackageId, Summary, SourceId, Source, Dependency, Registry};
 use ops;
-use util::{CargoResult, internal, internal_error, human, ChainError, Config};
+use util::{self, CargoResult, internal, internal_error, human, ChainError, Config};
 
 pub struct PathSource<'a, 'b: 'a> {
     id: SourceId,
@@ -99,7 +99,7 @@ impl<'a, 'b> PathSource<'a, 'b> {
                               .map(|p| parse(p)).collect::<Result<Vec<_>, _>>());
 
         let mut filter = |p: &Path| {
-            let relative_path = p.relative_from(&root).unwrap();
+            let relative_path = util::without_prefix(p, &root).unwrap();
             include.iter().any(|p| p.matches_path(&relative_path)) || {
                 include.len() == 0 &&
                  !exclude.iter().any(|p| p.matches_path(&relative_path))
@@ -163,9 +163,9 @@ impl<'a, 'b> PathSource<'a, 'b> {
 
             // TODO: the `entry` has a mode we should be able to look at instead
             //       of just calling stat() again
-            if fs::metadata(&file_path).map(|m| m.is_dir()) == Ok(true) {
+            if fs::metadata(&file_path).map(|m| m.is_dir()).unwrap_or(false) {
                 warn!("  found submodule {}", file_path.display());
-                let rel = file_path.relative_from(&root).unwrap();
+                let rel = util::without_prefix(&file_path, &root).unwrap();
                 let rel = try!(rel.to_str().chain_error(|| {
                     human(format!("invalid utf-8 filename: {}", rel.display()))
                 }));
@@ -219,7 +219,7 @@ impl<'a, 'b> PathSource<'a, 'b> {
                    is_root: bool, filter: &mut F) -> CargoResult<()>
             where F: FnMut(&Path) -> bool
         {
-            if fs::metadata(&path).map(|m| m.is_dir()) != Ok(true) {
+            if !fs::metadata(&path).map(|m| m.is_dir()).unwrap_or(false) {
                 if (*filter)(path) {
                     ret.push(path.to_path_buf());
                 }
index 75bbcf10edf42cf49fd59e788be98321694ed602..4c24b34c59b8d0fd18c7a013929460ee2c240b44 100644 (file)
@@ -1,4 +1,4 @@
-use std::error::{FromError, Error};
+use std::error::Error;
 use std::ffi;
 use std::fmt;
 use std::io;
@@ -233,8 +233,8 @@ impl CliError {
     }
 }
 
-impl FromError<Box<CargoError>> for CliError {
-    fn from_error(err: Box<CargoError>) -> CliError {
+impl From<Box<CargoError>> for CliError {
+    fn from(err: Box<CargoError>) -> CliError {
         CliError::from_boxed(err, 101)
     }
 }
@@ -244,8 +244,8 @@ impl FromError<Box<CargoError>> for CliError {
 
 macro_rules! from_error {
     ($($p:ty,)*) => (
-        $(impl FromError<$p> for Box<CargoError> {
-            fn from_error(t: $p) -> Box<CargoError> { Box::new(t) }
+        $(impl From<$p> for Box<CargoError> {
+            fn from(t: $p) -> Box<CargoError> { Box::new(t) }
         })*
     )
 }
@@ -264,8 +264,8 @@ from_error! {
     ffi::NulError,
 }
 
-impl<E: CargoError> FromError<Human<E>> for Box<CargoError> {
-    fn from_error(t: Human<E>) -> Box<CargoError> { Box::new(t) }
+impl<E: CargoError> From<Human<E>> for Box<CargoError> {
+    fn from(t: Human<E>) -> Box<CargoError> { Box::new(t) }
 }
 
 impl CargoError for semver::ReqParseError {}
@@ -278,7 +278,6 @@ impl CargoError for CliError {}
 impl CargoError for toml::Error {}
 impl CargoError for toml::DecodeError {}
 impl CargoError for url::ParseError {}
-impl CargoError for str::Utf8Error {}
 impl CargoError for ffi::NulError {}
 
 // =============================================================================
index 8ce77ea68432632aeb61ab8e467939ae1a1be977..095884d776d4bcbeff1d25e48d540f8916479e7f 100644 (file)
@@ -5,7 +5,7 @@ pub use self::errors::{CliError, ProcessError};
 pub use self::errors::{process_error, internal_error, internal, human};
 pub use self::errors::{Human, caused_human};
 pub use self::paths::{join_paths, path2bytes, bytes2path, dylib_path};
-pub use self::paths::{normalize_path, dylib_path_envvar};
+pub use self::paths::{normalize_path, dylib_path_envvar, without_prefix};
 pub use self::lev_distance::{lev_distance};
 pub use self::hex::{to_hex, short_hash};
 pub use self::dependency_queue::{DependencyQueue, Fresh, Dirty, Freshness};
index c7c749deec15016cc7f91be770b856b2c5cc8d2c..a758b58c9c681c34841dc8005dfa2a65891d0674 100644 (file)
@@ -1,14 +1,12 @@
 use std::env;
-use std::ffi::{AsOsStr, OsString};
+use std::ffi::{OsStr, OsString};
 use std::path::{Path, PathBuf, Component};
 
 use util::{human, internal, CargoResult, ChainError};
 
-pub fn join_paths<T: AsOsStr>(paths: &[T], env: &str) -> CargoResult<OsString> {
+pub fn join_paths<T: AsRef<OsStr>>(paths: &[T], env: &str) -> CargoResult<OsString> {
     env::join_paths(paths.iter()).or_else(|e| {
-        let paths = paths.iter().map(|p| {
-            Path::new(p.as_os_str())
-        }).collect::<Vec<_>>();
+        let paths = paths.iter().map(Path::new).collect::<Vec<_>>();
         internal(format!("failed to join path array: {:?}", paths)).chain_error(|| {
             human(format!("failed to join search paths together: {}\n\
                            Does ${} have an unterminated quote character?",
@@ -52,6 +50,21 @@ pub fn normalize_path(path: &Path) -> PathBuf {
     return ret;
 }
 
+pub fn without_prefix<'a>(a: &'a Path, b: &'a Path) -> Option<&'a Path> {
+    let mut a = a.components();
+    let mut b = b.components();
+    loop {
+        let mut a2 = a.clone();
+        match (a2.next(), b.next()) {
+            (Some(x), Some(y)) if x == y => a = a2,
+            (Some(_), Some(_)) |
+            (None, Some(_)) => return None,
+            (Some(_), None) |
+            (None, None) => return Some(a.as_path()),
+        }
+    }
+}
+
 #[cfg(unix)]
 pub fn path2bytes(path: &Path) -> CargoResult<&[u8]> {
     use std::os::unix::prelude::*;
index 025ebcb303a4f33a6705274c63536fa728d31e82..81d3b92c3eb909d5594fb1a43a0471bdf4147071 100644 (file)
@@ -1,6 +1,6 @@
 use std::collections::HashMap;
 use std::env;
-use std::ffi::{OsString, AsOsStr};
+use std::ffi::{OsString, OsStr};
 use std::fmt;
 use std::path::Path;
 use std::process::{Command, Output};
@@ -28,26 +28,26 @@ impl fmt::Display for ProcessBuilder {
 }
 
 impl ProcessBuilder {
-    pub fn arg<T: AsOsStr + ?Sized>(&mut self, arg: &T) -> &mut ProcessBuilder {
-        self.args.push(arg.as_os_str().to_os_string());
+    pub fn arg<T: AsRef<OsStr>>(&mut self, arg: T) -> &mut ProcessBuilder {
+        self.args.push(arg.as_ref().to_os_string());
         self
     }
 
-    pub fn args<T: AsOsStr>(&mut self, arguments: &[T]) -> &mut ProcessBuilder {
+    pub fn args<T: AsRef<OsStr>>(&mut self, arguments: &[T]) -> &mut ProcessBuilder {
         self.args.extend(arguments.iter().map(|t| {
-            t.as_os_str().to_os_string()
+            t.as_ref().to_os_string()
         }));
         self
     }
 
-    pub fn cwd<T: AsOsStr + ?Sized>(&mut self, path: &T) -> &mut ProcessBuilder {
-        self.cwd = path.as_os_str().to_os_string();
+    pub fn cwd<T: AsRef<OsStr>>(&mut self, path: T) -> &mut ProcessBuilder {
+        self.cwd = path.as_ref().to_os_string();
         self
     }
 
-    pub fn env<T: AsOsStr + ?Sized>(&mut self, key: &str,
-                                    val: &T) -> &mut ProcessBuilder {
-        self.env.insert(key.to_string(), Some(val.as_os_str().to_os_string()));
+    pub fn env<T: AsRef<OsStr>>(&mut self, key: &str,
+                                val: T) -> &mut ProcessBuilder {
+        self.env.insert(key.to_string(), Some(val.as_ref().to_os_string()));
         self
     }
 
@@ -128,9 +128,9 @@ impl ProcessBuilder {
     }
 }
 
-pub fn process<T: AsOsStr + ?Sized>(cmd: &T) -> CargoResult<ProcessBuilder> {
+pub fn process<T: AsRef<OsStr>>(cmd: T) -> CargoResult<ProcessBuilder> {
     Ok(ProcessBuilder {
-        program: cmd.as_os_str().to_os_string(),
+        program: cmd.as_ref().to_os_string(),
         args: Vec::new(),
         cwd: try!(env::current_dir()).as_os_str().to_os_string(),
         env: HashMap::new(),
index d41d87a15d7bc20a2c4e0df79161fc8080cf96cb..e653ab0fcb041c42ce829a421cdbfc784a3ecf04 100644 (file)
@@ -3,7 +3,6 @@ use std::default::Default;
 use std::fmt;
 use std::fs;
 use std::path::{Path, PathBuf};
-use std::slice;
 use std::str;
 
 use toml;
@@ -15,7 +14,7 @@ use core::{Summary, Manifest, Target, Dependency, PackageId, GitReference};
 use core::dependency::Kind;
 use core::manifest::{LibKind, Profile, ManifestMetadata};
 use core::package_id::Metadata;
-use util::{CargoResult, human, ToUrl, ToSemver, ChainError, Config};
+use util::{self, CargoResult, human, ToUrl, ToSemver, ChainError, Config};
 
 /// Representation of the projects file layout.
 ///
@@ -99,11 +98,11 @@ pub fn to_manifest(contents: &[u8],
                    config: &Config)
                    -> CargoResult<(Manifest, Vec<PathBuf>)> {
     let manifest = layout.root.join("Cargo.toml");
-    let manifest = match manifest.relative_from(config.cwd()) {
+    let manifest = match util::without_prefix(&manifest, config.cwd()) {
         Some(path) => path.to_path_buf(),
         None => manifest.clone(),
     };
-    let contents = try!(str::from_utf8(contents).chain_error(|| {
+    let contents = try!(str::from_utf8(contents).map_err(|_| {
         human(format!("{} is not valid UTF-8", manifest.display()))
     }));
     let root = try!(parse(contents, &manifest));
@@ -204,7 +203,7 @@ pub struct TomlManifest {
     package: Option<Box<TomlProject>>,
     project: Option<Box<TomlProject>>,
     profile: Option<TomlProfiles>,
-    lib: Option<ManyOrOne<TomlLibTarget>>,
+    lib: Option<TomlLibTarget>,
     bin: Option<Vec<TomlBinTarget>>,
     example: Option<Vec<TomlExampleTarget>>,
     test: Option<Vec<TomlTestTarget>>,
@@ -235,21 +234,6 @@ pub struct TomlProfile {
     rpath: Option<bool>,
 }
 
-#[derive(RustcDecodable)]
-pub enum ManyOrOne<T> {
-    Many(Vec<T>),
-    One(T),
-}
-
-impl<T> ManyOrOne<T> {
-    fn as_slice(&self) -> &[T] {
-        match *self {
-            ManyOrOne::Many(ref v) => v,
-            ManyOrOne::One(ref t) => slice::ref_slice(t),
-        }
-    }
-}
-
 #[derive(RustcDecodable)]
 pub struct TomlProject {
     name: String,
@@ -305,14 +289,14 @@ struct Context<'a, 'b, 'c: 'b> {
 // otherwise acceptable executable names are not used when inside of
 // `src/bin/*`, but it seems ok to not build executables with non-UTF8
 // paths.
-fn inferred_lib_target(name: &str, layout: &Layout) -> Vec<TomlTarget> {
+fn inferred_lib_target(name: &str, layout: &Layout) -> Option<TomlTarget> {
     layout.lib.as_ref().map(|lib| {
-        vec![TomlTarget {
+        TomlTarget {
             name: name.to_string(),
             path: Some(PathValue::Path(lib.clone())),
             .. TomlTarget::new()
-        }]
-    }).unwrap_or(Vec::new())
+        }
+    })
 }
 
 fn inferred_bin_targets(name: &str, layout: &Layout) -> Vec<TomlTarget> {
@@ -388,24 +372,17 @@ impl TomlManifest {
         // If we have a lib with a path, we're done
         // If we have a lib with no path, use the inferred lib or_else package name
 
-        let mut used_deprecated_lib = false;
         let lib = match self.lib {
-            Some(ref libs) => {
-                match *libs {
-                    ManyOrOne::Many(..) => used_deprecated_lib = true,
-                    _ => {}
-                }
-                try!(libs.as_slice().iter().map(|t| {
-                    try!(validate_library_name(t));
-                    Ok(if layout.lib.is_some() && t.path.is_none() {
-                        TomlTarget {
-                            path: layout.lib.as_ref().map(|p| PathValue::Path(p.clone())),
-                            .. t.clone()
-                        }
-                    } else {
-                        t.clone()
-                    })
-                }).collect::<CargoResult<Vec<_>>>())
+            Some(ref lib) => {
+                try!(validate_library_name(lib));
+                Some(if layout.lib.is_some() && lib.path.is_none() {
+                    TomlTarget {
+                        path: layout.lib.as_ref().map(|p| PathValue::Path(p.clone())),
+                        .. lib.clone()
+                    }
+                } else {
+                    lib.clone()
+                })
             }
             None => inferred_lib_target(&project.name, layout),
         };
@@ -519,10 +496,6 @@ impl TomlManifest {
                                          project.links.clone(),
                                          metadata,
                                          profiles);
-        if used_deprecated_lib {
-            manifest.add_warning(format!("the [[lib]] section has been \
-                                          deprecated in favor of [lib]"));
-        }
         if project.license_file.is_some() && project.license.is_some() {
             manifest.add_warning(format!("warning: only one of `license` or \
                                                    `license-file` is necessary"));
@@ -652,7 +625,7 @@ impl fmt::Debug for PathValue {
     }
 }
 
-fn normalize(libs: &[TomlLibTarget],
+fn normalize(lib: &Option<TomlLibTarget>,
              bins: &[TomlBinTarget],
              custom_build: Option<PathBuf>,
              examples: &[TomlExampleTarget],
@@ -669,9 +642,8 @@ fn normalize(libs: &[TomlLibTarget],
               .set_for_host(toml.plugin.unwrap_or(t2.for_host()));
     }
 
-    fn lib_targets(dst: &mut Vec<Target>, libs: &[TomlLibTarget],
-                   metadata: &Metadata) {
-        let l = &libs[0];
+    fn lib_target(dst: &mut Vec<Target>, l: &TomlLibTarget,
+                  metadata: &Metadata) {
         let path = l.path.clone().unwrap_or_else(|| {
             PathValue::Path(Path::new("src").join(&format!("{}.rs", l.name)))
         });
@@ -764,14 +736,12 @@ fn normalize(libs: &[TomlLibTarget],
 
     let mut ret = Vec::new();
 
-    if libs.len() > 0 && bins.len() > 0 {
-        lib_targets(&mut ret, libs, metadata);
+    if let Some(ref lib) = *lib {
+        lib_target(&mut ret, lib, metadata);
         bin_targets(&mut ret, bins,
                     &mut |bin| Path::new("src").join("bin")
                                    .join(&format!("{}.rs", bin.name)));
-    } else if libs.len() > 0 && bins.len() == 0 {
-        lib_targets(&mut ret, libs, metadata);
-    } else if libs.len() == 0 && bins.len() > 0 {
+    } else if bins.len() > 0 {
         bin_targets(&mut ret, bins,
                     &mut |bin| Path::new("src")
                                     .join(&format!("{}.rs", bin.name)));
index 09053248bb5c00da1e6ca66715a17166641d972b..22e8ceff87b26eb7ea9e556a5ecd314764711a03 100644 (file)
@@ -1 +1 @@
-2015-03-30
+2015-04-02
index a8f535c6cdf76f8b2e671a7fb9d9c5016d1819c7..cda18976c7e09322e87794c42a8aea639a96b3ec 100644 (file)
@@ -1,6 +1,6 @@
 use std::env;
 use std::error::Error;
-use std::ffi::AsOsStr;
+use std::ffi::OsStr;
 use std::fmt;
 use std::fs;
 use std::io::prelude::*;
@@ -121,7 +121,7 @@ impl ProjectBuilder {
         self.root.join("target")
     }
 
-    pub fn process<T: AsOsStr + ?Sized>(&self, program: &T) -> ProcessBuilder {
+    pub fn process<T: AsRef<OsStr>>(&self, program: T) -> ProcessBuilder {
         let mut p = process(program).unwrap();
         p.cwd(&self.root()).env("HOME", &paths::home());
         return p;
index de82969ab1c5515682df736ef44f62357341b83b..2d643fbf203073d7f5a94a3948323e378ded7ea2 100644 (file)
@@ -179,7 +179,7 @@ test bench_hello ... ",
         COMPILING, p.url(), RUNNING))
               .with_stderr("\
 thread '<main>' panicked at 'assertion failed: \
-    `(left == right) && (right == left)` (left: \
+    `(left == right)` (left: \
     `\"hello\"`, right: `\"nope\"`)', src[..]foo.rs:14
 
 ")
index 1efe916053176a7c77bf2de06b85c859128f1435..3faea78b519c896e99ae43b1c7d7e4dada8b4f69 100644 (file)
@@ -1,6 +1,7 @@
 use std::env;
 use std::fs::{self, File};
 use std::io::prelude::*;
+use std::thread;
 use tempdir::TempDir;
 
 use support::{project, execs, main_file, basic_bin_manifest};
@@ -1186,21 +1187,6 @@ test!(staticlib_rlib_and_bin {
     assert_that(p.cargo_process("build").arg("-v"), execs().with_status(0));
 });
 
-test!(opt_out_of_lib {
-    let p = project("foo")
-        .file("Cargo.toml", r#"
-              lib = []
-
-              [package]
-              name = "foo"
-              authors = []
-              version = "0.0.1"
-        "#)
-        .file("src/lib.rs", "bad syntax")
-        .file("src/main.rs", "fn main() {}");
-    assert_that(p.cargo_process("build"), execs().with_status(0));
-});
-
 test!(opt_out_of_bin {
     let p = project("foo")
         .file("Cargo.toml", r#"
@@ -1232,24 +1218,6 @@ test!(single_lib {
     assert_that(p.cargo_process("build"), execs().with_status(0));
 });
 
-test!(deprecated_lib {
-    let p = project("foo")
-        .file("Cargo.toml", r#"
-              [package]
-              name = "foo"
-              authors = []
-              version = "0.0.1"
-
-              [[lib]]
-              name = "foo"
-        "#)
-        .file("src/foo.rs", "");
-    assert_that(p.cargo_process("build"),
-                execs().with_status(0)
-                       .with_stderr("\
-the [[lib]] section has been deprecated in favor of [lib]\n"));
-});
-
 test!(freshness_ignores_excluded {
     let foo = project("foo")
         .file("Cargo.toml", r#"
@@ -1572,8 +1540,7 @@ test!(compile_then_delete {
     assert_that(&p.bin("foo"), existing_file());
     if cfg!(windows) {
         // On windows unlinking immediately after running often fails, so sleep
-        use std::time::duration::Duration;
-        ::sleep(Duration::milliseconds(100));
+        thread::sleep_ms(100);
     }
     fs::remove_file(&p.bin("foo")).unwrap();
     assert_that(p.cargo("run"),
index dd7b6cee68f883019bdbf1ad4b3cbb6ada7228c5..ee438e03cd3a7364562b7353745ac39fcb3f9eb9 100644 (file)
@@ -99,7 +99,7 @@ test!(custom_build_env_vars {
 
                 let out = env::var("OUT_DIR").unwrap();
                 assert!(out.starts_with(r"{0}"));
-                assert_eq!(fs::metadata(&out).map(|m| m.is_dir()), Ok(true));
+                assert!(fs::metadata(&out).map(|m| m.is_dir()).unwrap_or(false));
 
                 let _host = env::var("HOST").unwrap();
 
index 4ea280cf3a87e7bb39b1aa32df8250d466472041..2382e4732732f31d870de8fb7e9365cd79cfb985 100644 (file)
@@ -1,7 +1,7 @@
 use std::fs::{self, File};
 use std::io::prelude::*;
 use std::path::Path;
-use std::time::Duration;
+use std::thread;
 use git2;
 
 use support::{ProjectBuilder, project, execs, main_file, path2url};
@@ -698,7 +698,7 @@ test!(update_with_shared_deps {
     add(&repo);
     commit(&repo);
 
-    ::sleep(Duration::milliseconds(1000));
+    thread::sleep_ms(1000);
 
     // By default, not transitive updates
     println!("dep1 update");
@@ -890,7 +890,7 @@ test!(stale_cached_version {
     add(&repo);
     commit(&repo);
 
-    ::sleep(Duration::milliseconds(1000));
+    thread::sleep_ms(1000);
 
     let rev = repo.revparse_single("HEAD").unwrap().id();
 
@@ -996,7 +996,7 @@ test!(dep_with_changed_submodule {
     add(&repo);
     commit(&repo);
 
-    ::sleep(Duration::milliseconds(1000));
+    thread::sleep_ms(1000);
     // Update the dependency and carry on!
     println!("update");
     assert_that(project.cargo("update").arg("-v"),
@@ -1094,7 +1094,7 @@ test!(git_build_cmd_freshness {
     }).unwrap();
     foo.root().move_into_the_past().unwrap();
 
-    ::sleep(Duration::milliseconds(1000));
+    thread::sleep_ms(1000);
 
     assert_that(foo.cargo("build"),
                 execs().with_status(0)
index c5288943067b811aa91533d1df006c27aa3d61b6..608a1b3a34cbc72ee268cb19d5e9da1da071add0 100644 (file)
@@ -1,6 +1,6 @@
 use std::fs::{self, File};
 use std::io::prelude::*;
-use std::time::Duration;
+use std::thread;
 
 use support::{project, execs, main_file};
 use support::{COMPILING, RUNNING};
@@ -352,7 +352,7 @@ test!(deep_dependencies_trigger_rebuild {
     //
     // We base recompilation off mtime, so sleep for at least a second to ensure
     // that this write will change the mtime.
-    ::sleep(Duration::seconds(1));
+    thread::sleep_ms(1000);
     File::create(&p.root().join("baz/src/baz.rs")).unwrap().write_all(br#"
         pub fn baz() { println!("hello!"); }
     "#).unwrap();
@@ -365,7 +365,7 @@ test!(deep_dependencies_trigger_rebuild {
                                             COMPILING, p.url())));
 
     // Make sure an update to bar doesn't trigger baz
-    ::sleep(Duration::seconds(1));
+    thread::sleep_ms(1000);
     File::create(&p.root().join("bar/src/bar.rs")).unwrap().write_all(br#"
         extern crate baz;
         pub fn bar() { println!("hello!"); baz::baz(); }
index c83b1406676caf63bb0d956dabbed96ce672587a..ada46bbc5f6d6667bc272ff8c40b9574266aa672 100644 (file)
@@ -64,7 +64,7 @@ test!(simple {
     let mut f = File::open(&upload_path().join("api/v1/crates/new")).unwrap();
     // Skip the metadata payload and the size of the tarball
     let mut sz = [0; 4];
-    assert_eq!(f.read(&mut sz), Ok(4));
+    assert_eq!(f.read(&mut sz).unwrap(), 4);
     let sz = ((sz[0] as u32) <<  0) |
              ((sz[1] as u32) <<  8) |
              ((sz[2] as u32) << 16) |
index 6cf457aee0a25cd6aad58ace0d88480916ba8b00..6c08c73aea7f7ebbbc9badb828f239e4a5ef5f94 100644 (file)
@@ -133,7 +133,7 @@ failures:
 
 ---- test_hello stdout ----
 <tab>thread 'test_hello' panicked at 'assertion failed: \
-    `(left == right) && (right == left)` (left: \
+    `(left == right)` (left: \
     `\"hello\"`, right: `\"nope\"`)', src[..]foo.rs:12
 
 
@@ -1166,11 +1166,8 @@ test!(example_dev_dep {
             macro_rules! f6( () => ({(f5!()) + (f5!())}) );
             macro_rules! f7( () => ({(f6!()) + (f6!())}) );
             macro_rules! f8( () => ({(f7!()) + (f7!())}) );
-            macro_rules! f9( () => ({(f8!()) + (f8!())}) );
-            macro_rules! f10( () => ({(f9!()) + (f9!())}) );
-            macro_rules! f11( () => ({(f10!()) + (f10!())}) );
             pub fn bar() {
-                f11!();
+                f8!();
             }
         "#);
     assert_that(p.cargo_process("test"),
index 00d6054e81e17bc6207ad59af888fc08b8e9939c..8be26db87c626a08d79fdec96a8e231b7f9dd208 100644 (file)
@@ -1,5 +1,4 @@
-#![feature(io, convert, thread_sleep)]
-#![feature(std_misc, io, fs, fs_ext, path_ext, fs_time, fs_walk)]
+#![feature(fs, fs_ext, path_ext, fs_time, fs_walk)]
 
 extern crate rustc_serialize;
 extern crate cargo;
@@ -53,7 +52,3 @@ mod test_cargo_search;
 mod test_cargo_test;
 mod test_cargo_version;
 mod test_shell;
-
-fn sleep(dur: std::time::Duration) {
-    std::thread::sleep(dur)
-}